package com.kate.mall.member.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.kate.mall.common.utils.PageUtils;
import com.kate.mall.common.utils.R;
import com.kate.mall.member.entity.FeedbackEntity;
import com.kate.mall.member.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;


/**
 * 意见反馈表
 *
 * @author kate-chan
 * @email ccsu_loader@163.com
 * @date 2021-10-08 16:10:48
 */
@Api(tags = "FeedbackController", description = "意见反馈表服务")
@RestController
@RequestMapping("user/feedback")
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("user:feedback:list")
    @ApiOperation("获取所有意见反馈表信息")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = feedbackService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("user:feedback:info")
    @ApiOperation("获取指定id的意见反馈表详情")
    public R info(@PathVariable("id") Integer id){
		FeedbackEntity feedback = feedbackService.getById(id);

        return R.ok().put("feedback", feedback);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("添加意见反馈表信息")
    //@RequiresPermissions("user:feedback:save")
    public R save(@RequestBody FeedbackEntity feedback){
		feedbackService.save(feedback);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @ApiOperation("更新指定id意见反馈表信息")
    //@RequiresPermissions("user:feedback:update")
    public R update(@RequestBody FeedbackEntity feedback){
		feedbackService.updateById(feedback);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @ApiOperation("删除指定id意见反馈表信息")
    //@RequiresPermissions("user:feedback:delete")
    public R delete(@RequestBody Integer[] ids){
		feedbackService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
